<?php
namespace App\Api\Movie;

use PhalApi\Api;
use App\Domain\Movie\MovieCategory as MovieCategoryDomain;
/**
 * 电影类目接口
 */
class MovieCategory extends Api
{
    public function getRules()
    {
        return array(
            'getList' => array(
            ),
            'update' => array(
                'id' => array('name' => 'id', 'require' => false),
                'pid' => array('name' => 'pid', 'require' => false),
                'name' => array('name' => 'name', 'require' => true),
                'alias_name' => array('name' => 'alias_name', 'require' => false),
            ),
            'delete'=> array(
                'id'=> array('name'=>'id','require'=>true)
            )
        );
    }
    /**
     * 获取电影类目列表
     * @desc 用于获取电影类目列表
     */
    public function getList() {
        $domain = new MovieCategoryDomain();
        $res = $domain->getList();
        return $res;
    }

    /**
     * 获取电影类目列表
     * @desc 用于后端电影类目列表
     */
    public function getCateList() {
        $domain = new MovieCategoryDomain();
        $res = $domain->getCateList();
        return $res;
    }
    /**
     * 更新或添加电影类目
     * @desc 有id则是更新无id则是添加
     */
    public function update() {
        $domain = new MovieCategoryDomain();
        $data=array(
            'pid'=>$this->pid,
            'name'=>$this->name,
            'alias_name'=>$this->alias_name,
            'update_time'=>date('Y-m-d H:i:s',time())
        );
        $res = $domain->update($this->id,$data);
        return $res;
    }
    /**
     * 删除电影分类
     * @desc 删除电影分类
     */
    public function delete() {
        $domain = new MovieCategoryDomain();
        $res = $domain->delete($this->id);
        return $res;
    }

}
